package com.bor.gb.rest.util;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

/**
 * Created by bor on 12/24/14.
 */
public class Response {

    public static class Error extends ResponseEntity {
        public Error(String body, HttpStatus statusCode) {
            super(new ErrorResponse(body), statusCode);
        }

        public Error(String msg) {
            super(new ErrorResponse(msg), HttpStatus.OK);
        }
    }

    public static class Msg extends ResponseEntity {
        public Msg(String body, HttpStatus statusCode) {
            super(new MsgResponse(body), statusCode);
        }
    }

    public static class Data<T> extends ResponseEntity {
        public Data(T body, HttpStatus statusCode) {
            super(body, statusCode);
        }
    }
}

/**
 *  POJO to Json mapping classes
 */
class MsgResponse {
    private String msg;

    MsgResponse(String msg) {
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}

class ErrorResponse {
    private String error;

    ErrorResponse(String error) {
        this.error = error;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }
}